
template<class T>
void readInNugent15(T myAst[], long indLastMPC, long indLastNumbMPC, string* ids, long nIds)
{
  string line;
  ifstream myfile ("Nugent_apj520685t4_mrt.txt");
  long ind;
  AsteroidWithPole ast;

  if (myfile.is_open())
  {
    for (int j=0; j<30; j++)  // Nugent File Header
      getline (myfile,line) ; // skip header

    while ( getline (myfile,line))
      if (line.length()>1)
	{
	  // convert linefile to asteroid
	  ast.Nugent15String2Asteroid(line);
      	  // if the asteroid is Numbered in the file assing it
	  if (ast.Number>0)
	    {
	      myAst[ast.Number-1].D=ast.D;
	      myAst[ast.Number-1].sigmaD=ast.sigmaD;
	      myAst[ast.Number-1].pV=ast.pV;
	      myAst[ast.Number-1].sigmapV=ast.sigmapV;
	      myAst[ast.Number-1].eta=ast.eta;
	      myAst[ast.Number-1].sigmaEta=ast.sigmaEta;
	      myAst[ast.Number-1].pIR=ast.pIR;
	      myAst[ast.Number-1].sigmapIR=ast.sigmapIR;
	      myAst[ast.Number-1].nW1=ast.nW1;
	      myAst[ast.Number-1].nW2=ast.nW1;
	      myAst[ast.Number-1].nW3=ast.nW3;
	      myAst[ast.Number-1].nW4=ast.nW4;
	      myAst[ast.Number-1].sigmapV=ast.sigmapV;
	      myAst[ast.Number-1].refs[3]+=NUGENT14;
	    }
	  else
	    {
	      // can you match is right there ?
	      if ((ind = findUnnumberedAst(myAst,ast,indLastMPC,indLastNumbMPC+1))>=0) // YES ! 
		{
		  myAst[ind].D=ast.D;
		  myAst[ind].sigmaD=ast.sigmaD;
		  myAst[ind].pV=ast.pV;
		  myAst[ind].sigmapV=ast.sigmapV;
		  myAst[ind].eta=ast.eta;
		  myAst[ind].sigmaEta=ast.sigmaEta;
		  myAst[ind].pIR=ast.pIR;
		  myAst[ind].sigmapIR=ast.sigmapIR;
		  myAst[ind].nW1=ast.nW1;
		  myAst[ind].nW2=ast.nW1;
		  myAst[ind].nW3=ast.nW3;
		  myAst[ind].nW4=ast.nW4;
		  myAst[ind].refs[3]+=NUGENT14;
		  //		  cout << ">>match 1  " << ast.pack << endl;
		}
	      else
		{ // the designation could not be matched.
		  // try to see if the asteroid has been numbered LATER
		  ast.findId(ids,nIds);
		  if (ast.Number>0)
		    {
		      myAst[ast.Number-1].D=ast.D;
		      myAst[ast.Number-1].sigmaD=ast.sigmaD;
		      myAst[ast.Number-1].pV=ast.pV;
		      myAst[ast.Number-1].sigmapV=ast.sigmapV;
		      myAst[ast.Number-1].eta=ast.eta;
		      myAst[ast.Number-1].sigmaEta=ast.sigmaEta;
		      myAst[ast.Number-1].pIR=ast.pIR;
		      myAst[ast.Number-1].sigmapIR=ast.sigmapIR;
		      myAst[ast.Number-1].nW1=ast.nW1;
		      myAst[ast.Number-1].nW2=ast.nW1;
		      myAst[ast.Number-1].nW3=ast.nW3;
		      myAst[ast.Number-1].nW4=ast.nW4;
		      myAst[ast.Number-1].sigmapV=ast.sigmapV;
		      myAst[ast.Number-1].refs[3]+=NUGENT14;
		      //		      cout << ">>match 2  " << ast.pack << endl;
		    }
		  else
		    {
		      if ((ind = findUnnumberedAst(myAst,ast,indLastMPC,indLastNumbMPC+1))>=0) // YES ! 
			{
			  myAst[ind].D=ast.D;
			  myAst[ind].sigmaD=ast.sigmaD;
			  myAst[ind].pV=ast.pV;
			  myAst[ind].sigmapV=ast.sigmapV;
			  myAst[ind].eta=ast.eta;
			  myAst[ind].sigmaEta=ast.sigmaEta;
			  myAst[ind].pIR=ast.pIR;
			  myAst[ind].sigmapIR=ast.sigmapIR;
			  myAst[ind].nW1=ast.nW1;
			  myAst[ind].nW2=ast.nW1;
			  myAst[ind].nW3=ast.nW3;
			  myAst[ind].nW4=ast.nW4;
			  myAst[ind].refs[3]+=NUGENT14;
			  //			  cout << ">>match 23  " << ast.pack << endl;
			}
		      else
			{
			  cout << ">>match FAILED  " << ast.pack << "--" << line << endl;
			}
		    }
		}
	    }
	}
    myfile.close();
  }
  else cout << "Unable to open file"; 
}


template<class T>
void readInNugent16MBA(T myAst[], long indLastMPC, long indLastNumbMPC, string* ids, long nIds)
{
  string line;
  ifstream myfile ("ajaa2caat5_mrt.txt"); // MAINBELT FILE 
  long ind;
  AsteroidWithPole ast;

  if (myfile.is_open())
  {
    for (int j=0; j<26; j++)  // Nugent File Header
      getline (myfile,line) ; // skip header

    while ( getline (myfile,line))
      if (line.length()>1)
	{
	  // convert linefile to asteroid
	  ast.Nugent16MBAString2Asteroid(line);
      	  // if the asteroid is Numbered in the file assing it
	  if (ast.Number>0)
	    {
	      myAst[ast.Number-1].D=ast.D;
	      myAst[ast.Number-1].sigmaD=ast.sigmaD;
	      myAst[ast.Number-1].pV=ast.pV;
	      myAst[ast.Number-1].sigmapV=ast.sigmapV;
	      myAst[ast.Number-1].eta=ast.eta;
	      myAst[ast.Number-1].sigmaEta=ast.sigmaEta;
	      myAst[ast.Number-1].pIR=ast.pIR;
	      myAst[ast.Number-1].sigmapIR=ast.sigmapIR;
	      myAst[ast.Number-1].nW1=ast.nW1;
	      myAst[ast.Number-1].nW2=ast.nW1;
	      myAst[ast.Number-1].nW3=ast.nW3;
	      myAst[ast.Number-1].nW4=ast.nW4;
	      myAst[ast.Number-1].sigmapV=ast.sigmapV;
	      myAst[ast.Number-1].refs[3]+=NUGENT14;
	    }
	  else
	    {
	      // can you match is right there ?
	      if ((ind = findUnnumberedAst(myAst,ast,indLastMPC,indLastNumbMPC+1))>=0) // YES ! 
		{
		  myAst[ind].D=ast.D;
		  myAst[ind].sigmaD=ast.sigmaD;
		  myAst[ind].pV=ast.pV;
		  myAst[ind].sigmapV=ast.sigmapV;
		  myAst[ind].eta=ast.eta;
		  myAst[ind].sigmaEta=ast.sigmaEta;
		  myAst[ind].pIR=ast.pIR;
		  myAst[ind].sigmapIR=ast.sigmapIR;
		  myAst[ind].nW1=ast.nW1;
		  myAst[ind].nW2=ast.nW1;
		  myAst[ind].nW3=ast.nW3;
		  myAst[ind].nW4=ast.nW4;
		  myAst[ind].refs[3]+=NUGENT14;
		  //		  cout << ">>match 1  " << ast.pack << endl;
		}
	      else
		{ // the designation could not be matched.
		  // try to see if the asteroid has been numbered LATER
		  ast.findId(ids,nIds);
		  if (ast.Number>0)
		    {
		      myAst[ast.Number-1].D=ast.D;
		      myAst[ast.Number-1].sigmaD=ast.sigmaD;
		      myAst[ast.Number-1].pV=ast.pV;
		      myAst[ast.Number-1].sigmapV=ast.sigmapV;
		      myAst[ast.Number-1].eta=ast.eta;
		      myAst[ast.Number-1].sigmaEta=ast.sigmaEta;
		      myAst[ast.Number-1].pIR=ast.pIR;
		      myAst[ast.Number-1].sigmapIR=ast.sigmapIR;
		      myAst[ast.Number-1].nW1=ast.nW1;
		      myAst[ast.Number-1].nW2=ast.nW1;
		      myAst[ast.Number-1].nW3=ast.nW3;
		      myAst[ast.Number-1].nW4=ast.nW4;
		      myAst[ast.Number-1].sigmapV=ast.sigmapV;
		      myAst[ast.Number-1].refs[3]+=NUGENT14;
		      //		      cout << ">>match 2  " << ast.pack << endl;
		    }
		  else
		    {
		      if ((ind = findUnnumberedAst(myAst,ast,indLastMPC,indLastNumbMPC+1))>=0) // YES ! 
			{
			  myAst[ind].D=ast.D;
			  myAst[ind].sigmaD=ast.sigmaD;
			  myAst[ind].pV=ast.pV;
			  myAst[ind].sigmapV=ast.sigmapV;
			  myAst[ind].eta=ast.eta;
			  myAst[ind].sigmaEta=ast.sigmaEta;
			  myAst[ind].pIR=ast.pIR;
			  myAst[ind].sigmapIR=ast.sigmapIR;
			  myAst[ind].nW1=ast.nW1;
			  myAst[ind].nW2=ast.nW1;
			  myAst[ind].nW3=ast.nW3;
			  myAst[ind].nW4=ast.nW4;
			  myAst[ind].refs[3]+=NUGENT14;
			  //			  cout << ">>match 23  " << ast.pack << endl;
			}
		      else
			{
			  cout << ">>match FAILED  " << ast.pack << "--" << line << endl;
			}
		    }
		}
	    }
	}
    myfile.close();
  }
  else cout << "Unable to open file"; 
}

template<class T>
void readInNugent16NEA(T myAst[], long indLastMPC, long indLastNumbMPC, string* ids, long nIds)
{
  string line;
  ifstream myfile ("ajaa2caat4_mrt.txt"); // NEAs FILE 
  long ind;
  AsteroidWithPole ast;

  if (myfile.is_open())
  {
    for (int j=0; j<26; j++)  // Nugent File Header
      getline (myfile,line) ; // skip header

    while ( getline (myfile,line))
      if (line.length()>1)
	{
	  // convert linefile to asteroid
	  ast.Nugent16NEAString2Asteroid(line);
      	  // if the asteroid is Numbered in the file assing it
	  if (ast.Number>0)
	    {
	      myAst[ast.Number-1].D=ast.D;
	      myAst[ast.Number-1].sigmaD=ast.sigmaD;
	      myAst[ast.Number-1].pV=ast.pV;
	      myAst[ast.Number-1].sigmapV=ast.sigmapV;
	      myAst[ast.Number-1].eta=ast.eta;
	      myAst[ast.Number-1].sigmaEta=ast.sigmaEta;
	      myAst[ast.Number-1].pIR=ast.pIR;
	      myAst[ast.Number-1].sigmapIR=ast.sigmapIR;
	      myAst[ast.Number-1].nW1=ast.nW1;
	      myAst[ast.Number-1].nW2=ast.nW1;
	      myAst[ast.Number-1].nW3=ast.nW3;
	      myAst[ast.Number-1].nW4=ast.nW4;
	      myAst[ast.Number-1].sigmapV=ast.sigmapV;
	      myAst[ast.Number-1].refs[3]+=NUGENT14;
	    }
	  else
	    {
	      // can you match is right there ?
	      if ((ind = findUnnumberedAst(myAst,ast,indLastMPC,indLastNumbMPC+1))>=0) // YES ! 
		{
		  myAst[ind].D=ast.D;
		  myAst[ind].sigmaD=ast.sigmaD;
		  myAst[ind].pV=ast.pV;
		  myAst[ind].sigmapV=ast.sigmapV;
		  myAst[ind].eta=ast.eta;
		  myAst[ind].sigmaEta=ast.sigmaEta;
		  myAst[ind].pIR=ast.pIR;
		  myAst[ind].sigmapIR=ast.sigmapIR;
		  myAst[ind].nW1=ast.nW1;
		  myAst[ind].nW2=ast.nW1;
		  myAst[ind].nW3=ast.nW3;
		  myAst[ind].nW4=ast.nW4;
		  myAst[ind].refs[3]+=NUGENT14;
		  //		  cout << ">>match 1  " << ast.pack << endl;
		}
	      else
		{ // the designation could not be matched.
		  // try to see if the asteroid has been numbered LATER
		  ast.findId(ids,nIds);
		  if (ast.Number>0)
		    {
		      myAst[ast.Number-1].D=ast.D;
		      myAst[ast.Number-1].sigmaD=ast.sigmaD;
		      myAst[ast.Number-1].pV=ast.pV;
		      myAst[ast.Number-1].sigmapV=ast.sigmapV;
		      myAst[ast.Number-1].eta=ast.eta;
		      myAst[ast.Number-1].sigmaEta=ast.sigmaEta;
		      myAst[ast.Number-1].pIR=ast.pIR;
		      myAst[ast.Number-1].sigmapIR=ast.sigmapIR;
		      myAst[ast.Number-1].nW1=ast.nW1;
		      myAst[ast.Number-1].nW2=ast.nW1;
		      myAst[ast.Number-1].nW3=ast.nW3;
		      myAst[ast.Number-1].nW4=ast.nW4;
		      myAst[ast.Number-1].sigmapV=ast.sigmapV;
		      myAst[ast.Number-1].refs[3]+=NUGENT14;
		      //		      cout << ">>match 2  " << ast.pack << endl;
		    }
		  else
		    {
		      if ((ind = findUnnumberedAst(myAst,ast,indLastMPC,indLastNumbMPC+1))>=0) // YES ! 
			{
			  myAst[ind].D=ast.D;
			  myAst[ind].sigmaD=ast.sigmaD;
			  myAst[ind].pV=ast.pV;
			  myAst[ind].sigmapV=ast.sigmapV;
			  myAst[ind].eta=ast.eta;
			  myAst[ind].sigmaEta=ast.sigmaEta;
			  myAst[ind].pIR=ast.pIR;
			  myAst[ind].sigmapIR=ast.sigmapIR;
			  myAst[ind].nW1=ast.nW1;
			  myAst[ind].nW2=ast.nW1;
			  myAst[ind].nW3=ast.nW3;
			  myAst[ind].nW4=ast.nW4;
			  myAst[ind].refs[3]+=NUGENT14;
			  //			  cout << ">>match 23  " << ast.pack << endl;
			}
		      else
			{
			  cout << ">>match FAILED  " << ast.pack << "--" << line << endl;
			}
		    }
		}
	    }
	}
    myfile.close();
  }
  else cout << "Unable to open file"; 
}
